package mk.gamemap.view.anime
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.events.EventDispatcher;

	public class BitmapAnime extends EventDispatcher implements IAnime
	{
		public var image:BitmapData
		private var _loop:int
		private var _name:String;
		private var _beginFrame:int;
		private var _totalFrames:int;
		private var _frame:int=0;
		private var arr:Array;
		function BitmapAnime(arr:Array,name:String):void{
			this.arr=arr;
			_name=name;
			_beginFrame=1
			_totalFrames=arr.length;
			image=arr[0];
		}
		
		public function get name():String{
			return _name
		}
		
		public function get source():DisplayObject{
			return new Bitmap(image);
		}
		
		public function get curFrame():int{
			return _frame+1;
		}
		
		public function get totalFrames():int{
			return _totalFrames;
		}
		
		public function get isEnd():Boolean{
			return curFrame==totalFrames;
		}
		
		public function get loop():int{
			return _loop;
		}
		public function set loop(num:int):void{
			_loop=num;
		}
		
		public function prevFrame():void{
		}
		
		public function nextFrame():void{
			if (curFrame<totalFrames){
				image=arr[_frame++]
			}else{
				_frame=0
			}
			
		}
		
		public function reset():void{
			
		}
		
	}
}